Implementing Algebraic Effects in C - "Monads for Free in C"

نویسنده

  • Daan Leijen
چکیده

We describe a full implementation of algebraic effects and handlers as a library in standard and portable C99, where effect operations can be used just like regular C functions. We use a formal operational semantics to guide the C implementation at every step where an evaluation context corresponds directly to a particular C execution context. Finally we show a novel extension to the formal semantics to describe optimized tail resumptions and prove that the extension is sound. This gives two orders of magnitude improvement to the performance of tail resumptive operations (up to about 150 million operations per second on a Core [email protected]) Updates: 2017-06-30: Added Section A.4 on C++ support. 2017-06-19: Initial version.

برای دانلود رایگان متن کامل این مقاله و بیش از 32 میلیون مقاله دیگر ابتدا ثبت نام کنید

ثبت نام

اگر عضو سایت هستید لطفا وارد حساب کاربری خود شوید

منابع مشابه

The categories of lattice-valued maps, equalities, free objects, and $mathcal C$-reticulation

In this paper, we study the concept of $mathcal C$-reticulation for the category $mathcal C$ whose objects are lattice-valued maps. The relation between the free objects in $mathcal C$ and the $mathcal C$-reticulation of rings and modules is discussed. Also, a method to construct $mathcal C$-reticulation is presented, in the case where $mathcal C$ is equational. Some relations between the conce...

متن کامل

Implementing monads for C++ template metaprograms

C++ template metaprogramming is used in various application areas, such as expression templates, static interface checking, active libraries, etc. Its recognized similarities to pure functional programming languages – like Haskell – make the adoption of advanced functional techniques possible. Such a technique is using monads, programming structures representing computations. Using them actions...

متن کامل

Implementing Monads for C + + Template Metaprograms ∗ Technical report TR -

C++ template metaprogramming is used in various application areas, such as expression templates, static interface checking, active libraries, etc. Its recognized similarities to pure functional programming languages – like Haskell – make the adoption of advanced functional techniques possible. Such a technique is using monads, programming structures representing computations. Using them actions...

متن کامل

Development of a Method for measuring Reactive Oxygen Radicals Levels In Vitro and Study the Effects of Vitamin C and E on Radical Production Reaction

Background: Free radicals and reactive oxygen species(ROS) are the most important factors in formation of oxidative stress reaction. Now, radical damage has been suggested to contribute to a wide variety of diseases such as Alzheimer, atherosclerosis and cancer. Transition metal ions in the presence of the various biomolecules produce these active compounds. The aim of this study is introducing...

متن کامل

Combining algebraic effects with continuations

We consider the natural combinations of algebraic computational effects such as side-effects, exceptions, interactive input/output, and nondeterminism with continuations. Continuations are not an algebraic effect, but previously developed combinations of algebraic effects given by sum and tensor extend, with effort, to include commonly used combinations of the various algebraic effects with con...

متن کامل

ذخیره در منابع من


  با ذخیره ی این منبع در منابع من، دسترسی به آن را برای استفاده های بعدی آسان تر کنید

عنوان ژورنال:

دوره   شماره 

صفحات  -

تاریخ انتشار 2017